<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>query2</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link href="/static/css/reset.css" rel="stylesheet">
    <!-- Bootstrap3.3.5 CSS -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/css/query.css">
  </head>
  <body>
    <div class="container">
      <h2>电子证件核验</h2>
      <div id="query">
            <div class="left">
              <form  method="post" name="queryForm">
                  <p>
                  <div class="headImg">
                      <div class="uploadImg">
                          <input type="file" name="" value="上传照片" id="file">
                          +
                          <img src="" alt="">
                      </div>
                  </div>
                  </p>
                <a href="/index">返回首页</a>
                <a href="/queryPage">电子证件存证</a>
              </form>
            </div>

      </div>
    </div>
  </body>
  <script type="text/javascript" src="/static/js/jquery.min.js"></script>
  <script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
  <script type="text/javascript">
      $(function() {
          // 上传图片
          $('#file').unbind('change').bind('change',function() {
              event.stopPropagation();
              uploadFile('img');
              return;
          });
          // 头像图片
          var artImg;
          function uploadFile(type) {
              event.stopPropagation();
              let formData = new FormData();
              if( type == "img"){
                  formData.append('file', $('#file')[0].files[0]);
              }
              $.ajax({
                  url: '/dataVerification',
                  type: 'POST',
                  cache: false,
                  data: formData,
                  processData: false,
                  dataType: "json",
                  contentType: false
              }).done(function (res) {
                  if (res.error == "0") {
                      if( type == "img"){
                          // $('.uploadImg img').attr('src',res.result.path);
                          // $('#photo').val(res.result.path)
                          $('#photo').val("")
                          alert("验证通过，链上存在该存证内容!" )
                      }
                  } else {
                      alert("验证失败，链上不存在该存证内容！" + res.result.msg)
                  }
              }).fail(function (res) { });
          }
      })
  </script>
</html>
